home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8439 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Problem Negating an Unsigned Char
  5. Date: 4 Mar 1996 01:17:52 -0600
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4he5f0$acv@solutions.solon.com>
  8. References: <Dnnros.Lq.0.-s@hkusuc.hku.hk> <4he27sINNdel@keats.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: solutions.solon.com
  10.  
  11. In article <4he27sINNdel@keats.ugrad.cs.ubc.ca>,
  12. Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
  13. >To make it portable, you must manually mask for the lower eight bits:
  14.  
  15. >    if (a == (~b & 0xff))
  16.  
  17. Close, but the cigar yet escapes you.
  18.  
  19.     if (a == (~b & ((1 << CHAR_BIT) - 1)))
  20.  
  21. Further, you can't do this portably; if sizeof(long) is 1, the
  22. shift is illegal.
  23.  
  24. You could add ifdefs for this; enjoy!
  25.  
  26. -s
  27. -- 
  28. Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
  29. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  30. FUCK the communications decency act.  Goddamned government.  [literally.]
  31. The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
  32.